-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
TST: Add regression test for groupby().apply() external mutation #63126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
pandas-devGH-40673: Adds a test case to prevent regression of a bug where the internal object reused by apply() would corrupt externally stored DataFrames created with .copy(). This test verifies that store[0] and store[1] correctly contain independent copies of their respective groups.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
|
All CI checks passed, the pull request is ready for review but i don't see a button to request a reviewer. |
rhshadrach
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR - looking good!
| # The expected output in store dict | ||
| expected_out = {0: df[out_mask[0]], 1: df[out_mask[1]]} | ||
|
|
||
| tm.assert_frame_equal(store[0], expected_out[0].drop("B", axis=1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected here can just be df.iloc[[0, 2], 1] I think.
| expected_out = {0: df[out_mask[0]], 1: df[out_mask[1]]} | ||
|
|
||
| tm.assert_frame_equal(store[0], expected_out[0].drop("B", axis=1)) | ||
| tm.assert_frame_equal(store[1], expected_out[1].drop("B", axis=1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly here.
| } | ||
| ) | ||
|
|
||
| # Empty dict to hold the chunks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment and the ones below don't add anything that isn't already in the code. Can you remove them.
GH-40673: Adds a test case to prevent regression of a bug where the internal object reused by apply() would corrupt externally stored DataFrames created with .copy(). This test verifies that store[0] and store[1] correctly contain independent copies of their respective groups.
doc/source/whatsnew/vX.X.X.rstfile if fixing a bug or adding a new feature.AGENTS.md.